package com.casa.POI.dianping;

public class Spider {
	
	private Integer[] cities;
	
	public Spider(Integer... cities) {
		this.setCities(cities);
	}
	
	public void setCities(Integer[] cities) {
		this.cities = cities;
	}
	
	public Integer[] getCities() {
		return this.cities;
	}
	
	public void run() {
		TimeUtils.resetGlobalStartTime();
		Console.writeLine("spider started");
		processCities();
		new CleanupExecutor().execute();
	}

	public void processCities() {
		for (Integer cityId : this.getCities()) {
			Console.writeLine("process city %d...", cityId);
			new SpideCityExecutor(cityId).execute();
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Spider(ConfigurationManager.getInstance().getCities()).run();
	}

}
